import axios from 'axios'
import nProgress from 'nprogress'

const request = axios.create({
  baseURL: '/163api',
  timeout: 10000
})
request.interceptors.request.use((config) => {

  // 开启进度条
  nProgress.start()
  return config
})

request.interceptors.response.use((res) => {

  // 关闭进度条
  nProgress.done()

  return res.data.data
}, (err) => {
  // 关闭进度条
  nProgress.done()
  return Promise.reject(err)
})

export default request 